import argparse
import os
import sys

import command


def rm():
    parser = argparse.ArgumentParser(description='删除文件或目录')
    parser.add_argument('-p', '--path', nargs='?', default='', help='目录或文件')
    args, unknown_args = parser.parse_known_args()
    if len(unknown_args) == 0:
        print("Please enter a path")
        sys.exit()
    path = unknown_args[0]
    if os.path.isfile(path):
        command_line = f"del /q {path}"
    else:
        command_line = f"rmdir /s {path}"
    command.exe_command(command_line)


if __name__ == '__main__':
    rm()
